<!--乙供物资明细列表-->
<template>
    <u-collapse-item ref="supplyMaterial" :open="true">
        <text slot="title" class="u-page__title">乙供物资明细</text>
        <text class="u-collapse-content">
            <view style="padding: 0 16rpx">
                <view v-for="(item,index) in dataList" :key="index" style="background-color: #FFFFFF;margin-bottom: 20rpx;padding:10rpx 8rpx;color: #303133;border: 2rpx solid #dbdbdb;border-radius: 10rpx">
                    <view style="display: flex;justify-content: space-between;padding: 20rpx">
                        <view style="color: #CA171D;font-size: 32rpx;line-height: 40rpx">服务类型：{{configArray[item.configType]}}</view>
                        <view style="color: #4D88FF;font-size: 28rpx;line-height: 40rpx" @click="jump(item)">查看明细</view>
                    </view>
                    <view :class="[i % 2 == 0 ? 'gray' : '']" style="font-size: 32rpx;padding: 20rpx;line-height: 40rpx" v-for="(v,i) in formItem" :key="i">{{v.label}}：{{item[v.value]}}</view>
                </view>
                <view style="text-align: center;line-height: 200rpx;" v-if="dataList.length === 0">暂无数据</view>
            </view>
        </text>
    </u-collapse-item>
</template>

<script>
export default {
    components: {
    },
    props:{
        prjDetail: {
            type: Object,
            required: true,
            default: () => ({})
        },
        prjType: {
            type: String,
            required: true,
        }
    },
    data() {
        return {
            dataList:[],
            configArray:{
                1:'总包服务',
                2:'外电引入施工服务',
                3:'砖混/框架机房服务'
            },
            formItem:[
                {
                    label:'服务编码',
                    value:'materialCode'
                },
                {
                    label:'物料名称',
                    value:'materialName'
                },
                {
                    label:'累计验工计价金额',
                    value:'sumMoney'
                }
            ]
        }
    },
    mounted() {
        if(this.prjDetail.manageMode !== '01' && this.prjType!=='M'){
            this.formItem.unshift({
                label:'子项目编码',
                value:'prjCode'
            })
        }
        this.getServiceDetail();
    },
    methods:{
        getServiceDetail(){
            this.$axios.post('/material/api/service/serviceDetailConfig/getServiceDetailConfigForApp',{prjId:this.prjDetail.prjId}).then((res)=>{
                this.dataList=res.data;
                this.$nextTick(() => {
                    this.$refs.supplyMaterial.init()
                })
            })
        },
        jump(item){
            if(item.serviceDetailEntityList){
                // uni.navigateTo({
                //     url:"/inspur/acceptance/supplyMaterialDetail?item=" + encodeURIComponent(JSON.stringify(item.serviceDetailEntityList)),
                // })

                imp.iWindow.open({url:`${process.uniEnv.BASE_ZR_URL}/#/inspur/acceptance/supplyMaterialDetail?item=${encodeURIComponent(JSON.stringify(item.serviceDetailEntityList))}`})
            }else{
                console.log('没有明细可查询')
            }
        }
    }
}
</script>

<style>@import "@/common/common-ui.css";</style>
<style>@import "@/common/uView.css";</style>
<style scoped lang="scss">
.u-page{
    .u-collapse-body{
        height: auto !important;
    }
}
.gray{
    background-color:#efefef;
}
</style>